﻿using IntelligentAgriculture.Contracts.Dto.Input.ManageInput;
using IntelligentAgriculture.Contracts.Interface.IManagements;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.ManageCommand;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.ManageHandler
{
    public class ManageAddCommandHander : IRequestHandler<ManagerAddCommand, Results<int>>
    {
        private readonly IManageService _manageService;

        public ManageAddCommandHander(IManageService manageService)
        {
            _manageService = manageService;
        }
        /// <summary>
        /// 执行耳标添加操作
        /// </summary>
        /// <param name="request">包含耳标添加所需的请求信息</param>
        /// <param name="cancellationToken">用于取消操作的令牌</param>
        /// <returns>返回一个表示耳标添加操作结果的任务</returns>
        public async Task<Results<int>> Handle(ManagerAddCommand request, CancellationToken cancellationToken)
        {
            int manage =await _manageService.Add(request.ManagerInput);
            return Results<int>.DataResult(manage);
        }
    }


}
